package org.gis.mvc.controller;

import org.gis.mvc.view.ResultViewFactory;
import org.gis.mapserver.manager.ProcessingManager;
import org.gis.mvc.parser.RequestParser;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.gis.mapserver.responsewriter.ResponseWriter;
import org.gis.mvc.bean.RequestBean;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.mvc.Controller;

/**
 *
 * @author gus
 */
public class ProcessingController implements Controller
{
    public static final String RESPONSE_BEAN_KEY = "RESPONSE_BEAN";
    private ProcessingManager processingManager;

    public void setProcessingManager( ProcessingManager processingManager )
    {
        this.processingManager = processingManager;
    }

    @Override
    public ModelAndView handleRequest( HttpServletRequest request, HttpServletResponse response ) throws Exception
    {
        RequestBean requestBean = RequestParser.getRequestBean(request);
        ResponseWriter responseWriter = processingManager.processing(requestBean);
       
        View view = ResultViewFactory.createView(requestBean, responseWriter);
        return new ModelAndView(view);
    }
}